package com.abbas.smartCity.ui.movie;

import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.abbas.smartCity.App;
import com.abbas.smartCity.R;
import com.abbas.smartCity.base.BaseActivity;
import com.abbas.smartCity.bean.movie.MovieList;
import com.bumptech.glide.Glide;
import com.google.gson.Gson;

public class MovieDetailActivity extends BaseActivity {

    private ImageView im;
    private TextView name;
    private TextView tag1;
    private TextView tag2;
    private TextView tag3;
    private TextView tag4;
    private RatingBar rating;
    private Button back;



    @Override
    protected int getLayoutId() {
        return R.layout.activity_movie_detail;
    }

    @Override
    protected String setCustomTitle() {
        return "电影详情";

    }

    @Override
    protected void initView() {
        im = (ImageView) findViewById(R.id.im);
        name = (TextView) findViewById(R.id.name);
        tag1 = (TextView) findViewById(R.id.tag1);
        tag2 = (TextView) findViewById(R.id.tag2);
        tag3 = (TextView) findViewById(R.id.tag3);
        tag4 = (TextView) findViewById(R.id.tag4);
        rating = (RatingBar) findViewById(R.id.rating);
        back = (Button) findViewById(R.id.back);
    }

    @Override
    protected void initData() {
        final String data = getIntent().getStringExtra("data");
        MovieList.RowsBean movie = new Gson().fromJson(data,MovieList.RowsBean.class);

        Glide.with(this)
                .load(App.getBaseUrl() + movie.getCover())
                .error(R.drawable.ic_baseline_broken_image_24)
                .into(im);

        name.setText(movie.getName());
        tag1.setText("上映时间：" + movie.getPlayDate());
        tag2.setText("想看人数：" + movie.getLikeNum());
        tag3.setText("看过人数：" + movie.getFavoriteNum());
        tag4.setText("简介：" + movie.getIntroduction());

        rating.setRating(movie.getScore());
        rating.setIsIndicator(true);
    }

    @Override
    protected void initEvent() {
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MovieDetailActivity.this.finish();
            }
        });
    }
}